SG RegExp | |
RegExp Object |
Overview | Properties | Methods | Pattern Syntax |
SG RegExp is regular expression pattern search object for use with VBScript® scripts. You feed SG RegExp with pattern and string, and SG RegExp returns collection of matched strings.
To use it you first assign regular expression pattern to the Expression property, then call Match method with string you want to parse. If there were any matches they are returned in the Substrings collection.
re.Expression = "(.*);(.*);(.*)" bMatched = re.Match("red;green;blue") if bMatched then for each s in re.Substrings MsgBox s next end if
After succesfull match you can construct new string with matched substrings. Use ReplaceString method to retrieve replacement string:
Dim sResult sResult = re.ReplaceString("\1-\2-\3")
After this code is executed, sResult will contain string "red-green-blue".
For more info on pattern syntax click here.